/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.InternalStructures;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.BasicComponents.ConnectorKind;
import edu.pku.sei.modeler.model.uml.Kernel.Association;
import edu.pku.sei.modeler.model.uml.BasicBehaviors.Behavior;
import edu.pku.sei.modeler.model.uml.BehaviorStateMachines.PseudostateKind;

import edu.pku.sei.modeler.model.uml.Kernel.Feature;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Connector extends Feature implements IConnectors {
	// attributes
	
	protected ConnectorKind kind;
	
	// references
	
	protected MetaTypedList redefinedConnector;
	
	protected MetaTypedList type;
	
	protected MetaTypedList end;
	
	protected MetaTypedList contract;
	
	public Connector(ConnectorKind kind){
		this.kind = kind;
	}
	
	// getters & setters for attributes
	
	public ConnectorKind getKind() {
		return kind;
	}
	public void setKind(ConnectorKind newKind) {
		ConnectorKind oldkind = kind;
		kind = newKind;
		firePropertyChange(ModelPackage.CONNECTORS_KIND, oldkind, newKind);
	}
	
	// getters for references
	
	public MetaTypedList getRedefinedConnector() {
		if(redefinedConnector == null) {
			redefinedConnector = new MetaTypedList(Connector.class, this, ModelPackage.CONNECTORS_REDEFINEDCONNECTOR);
		}
		return redefinedConnector;
	}
	
	public MetaTypedList getType() {
		if(type == null) {
			type = new MetaTypedList(Association.class, this, ModelPackage.CONNECTORS_TYPE);
		}
		return type;
	}
	
	public MetaTypedList getEnd() {
		if(end == null) {
			end = new MetaTypedList(ConnectorEnd.class, this, ModelPackage.CONNECTORS_END);
		}
		return end;
	}
	
	public MetaTypedList getContract() {
		if(contract == null) {
			contract = new MetaTypedList(Behavior.class, this, ModelPackage.CONNECTORS_CONTRACT);
		}
		return contract;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
//		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.CONNECTORS_KIND, kind);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.CONNECTORS_REDEFINEDCONNECTOR, redefinedConnector);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.CONNECTORS_TYPE, type);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.CONNECTORS_END, end);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.CONNECTORS_CONTRACT, contract);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
//		kind = (ConnectorKind)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.CONNECTORS_KIND, this);
		
		// references
		
		this.getRedefinedConnector().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.CONNECTORS_REDEFINEDCONNECTOR, this));
		
		this.getType().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.CONNECTORS_TYPE, this));
		
		this.getEnd().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.CONNECTORS_END));
		
		this.getContract().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.CONNECTORS_CONTRACT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.CONNECTORS_KIND.equals(featureID)) {
			kind = (ConnectorKind)value;
		}
		
		// references
		
		else if(ModelPackage.CONNECTORS_REDEFINEDCONNECTOR.equals(featureID)) {
			getRedefinedConnector().add(value);
		}
		
		else if(ModelPackage.CONNECTORS_TYPE.equals(featureID)) {
			getType().add(value);
		}
		
		else if(ModelPackage.CONNECTORS_CONTRACT.equals(featureID)) {
			getContract().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 